import 'dart:async';

import 'package:fish_redux/fish_redux.dart';

enum ClassListAction {
  onLoad,
  listResult,
  loading,
  loaded,
  onReload,
  onDelete,
  deleted,
  onAdd,
}

class ClassListActionCreator {
  static Action onLoad() {
    return Action(ClassListAction.onLoad);
  }

  static Action loading() {
    return Action(ClassListAction.loading);
  }

  static Action loaded() {
    return Action(ClassListAction.loaded);
  }

  static Action listResult(List items, var pageTotal, var pageIndex) {
    return Action(ClassListAction.listResult, payload: {
      'items': items,
      "pageTotal": pageTotal,
      "pageIndex": pageIndex
    });
  }

  static Action onReload(callback) {
    return Action(ClassListAction.onReload, payload: callback);
  }

  static Action onDelete(String id) {
    return Action(ClassListAction.onDelete, payload: id);
  }

  static Action deleted(String code) {
    return Action(ClassListAction.deleted, payload: code);
  }

  static Action onAdd() {
    return const Action(ClassListAction.onAdd);
  }
}
